package Stack;

import Queue.Queue;

import java.util.Random;

public class ArrayCompareLinkedList {

    public static void main(String[] args) {
        int opCount = 100000;
        Stack<Integer> arrayStack = new ArrayStack<Integer>();
        testStack(arrayStack,opCount);
        Stack<Integer> linkedListStack = new LinkedListStack<Integer>();
        testStack(linkedListStack,opCount);
    }

    private static void testStack(Stack<Integer> stack, int opCount){
        long start = System.nanoTime();
        Random random = new Random();
        for (int i = 0; i < opCount; i++) {
            stack.push(random.nextInt(Integer.MAX_VALUE));
        }
        for (int i = 0; i < opCount; i++) {
            stack.pop();
        }
        long end = System.nanoTime();
        System.out.println(stack.getClass()+"耗时:"+(end-start)/1000000000.0);
    }
}
